<template>
  <div class="subscribe">
    <div class="search_box_top">
      <a-tabs v-model:activeKey="activeKey">
        <a-tab-pane :key="item.id" v-for="item in activeLiss">
          <template #tab>
            <span @click="activeClick(item)">
              {{ item.name }}
              <span v-if="item.name == '品牌'" class="Beta">Beta</span>
            </span>
          </template>
        </a-tab-pane>
      </a-tabs>
      <Signals v-if="activeKey == '1'" />
      <Provider v-if="activeKey == '2'" />
      <Purchases v-if="activeKey == '3'" />
      <Branding v-if="activeKey == '4'" />
      <Projections v-if="activeKey == '5'" />
      <Proposed v-if="activeKey == '6'" />
      <BiddingAgent v-if="activeKey == '7'" />
      <Operation v-if="activeKey == '8'" />
    </div>
    <div class="subskeyword">
      <div class="subsk_top">
        <img style="width: 16px; height: 16px" src="@/assets/img/mypoints/gjz.png" alt="" />
        <span class="subsk_wds">订阅关键词</span>
      </div>
      <div style="margin-top: 15px">
        <el-button class="button-new-tag ml-1" size="small" @click="inputVisible = true">
          + 添加
        </el-button>
        <el-tag v-for="tag in dynamicTags" style="margin-left: 15px" :key="tag" class="mx-1" closable
          :disable-transitions="false" @close="handleClose(tag)">
          {{ tag }}
        </el-tag>
      </div>
    </div>
    <el-dialog v-model="inputVisible" title="添加关键词" width="30%" style="height: 240px"
      :before-close="handleInputConfirm">
      <div style="text-align: center; margin: 50px 0">
        <el-input style="width: 400px" v-model="inputValue" placeholder="请输入关键词(10字符以内)" />
      </div>
      <template #footer>
        <div style="text-align: center">
          <el-button @click="inputVisible = false">取消</el-button>
          <el-button type="primary" color="#6675FF" style="color: #fff" @click="defineClick">
            确定
          </el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup>
import { ref } from "vue";
import Signals from "../../../../search/computer/signals/index.vue";
import Provider from "../../../../search/computer/provider/index.vue";
import Purchases from "../../../../search/computer/purchases/index.vue";
import Branding from "../../../../search/computer/branding/index.vue";
import Projections from "../../../../search/computer/projections/index.vue";
import Proposed from "../../../../search/computer/proposed/index.vue";
import BiddingAgent from "../../../../search/computer/biddingAgent/index.vue";
import Operation from "../../../../search/computer/operation/index.vue";

import { useRadio1Store } from "@/pain/search/search.js";
const signalsRadio1 = useRadio1Store();
let activeKey = ref("1");

let activeLiss = [
  {
    id: "1",
    name: "全部标讯",
  },
  {
    id: "2",
    name: "供应商",
  },
  {
    id: "3",
    name: "采购商",
  },
  {
    id: "4",
    name: "品牌",
  },
  {
    id: "5",
    name: "招标预测",
  },
  {
    id: "6",
    name: "拟建项目",
  },
  {
    id: "7",
    name: "招标代理机构",
  },
  {
    id: "8",
    name: "公司",
  },
];

const activeClick = (id) => {
  activeKey.value = id.id;
  signalsRadio1.id = id.id;
  console.log(activeKey.value);
};

const inputValue = ref("");
const dynamicTags = ref(["大数据", "阀门", "云计算"]);
const inputVisible = ref(false);

const handleClose = (tag) => {
  dynamicTags.value.splice(dynamicTags.value.indexOf(tag), 1);
};

const handleInputConfirm = (done) => {
  done();
};

const defineClick = () => {
  if (inputValue.value) {
    dynamicTags.value.push(inputValue.value);
  }
  inputVisible.value = false;
  inputValue.value = "";
};
</script>

<style lang="scss" scoped>
.subscribe {
  //   height: 100vh;
  padding: 20px;
  background-color: #fff;
}

.el-tag {
  padding: 15px;
}

.search_box_top {
  .Beta {
    width: 30px;
    height: 14px;
    background: #fb4204;
    padding: 2px;
    border-radius: 3px;
    color: #f6f6f6;
  }
}

.subskeyword {
  height: 756px;
  margin-top: 15px;
  padding-left: 20px;
  background: linear-gradient(180deg, #e6e9ff 0%, rgba(230, 233, 255, 0) 15%);
  border-radius: 8px;

  .subsk_top {
    display: flex;
    align-items: center;
    height: 56px;
    border-bottom: 1px solid #dbdfff;

    .subsk_wds {
      margin-left: 15px;
      font-size: 16px;
      color: #304156;
    }
  }
}

::v-deep .el-button--small {
  padding: 15px;
}
</style>
